package asava.tools;

import asava.utils.Position;
import asava.utils.Problem;

import java.util.LinkedList;
import java.util.List;

/**
 * @author Tim Richter
 */
public final class Reporter {
    public final List<Problem> errors;
    public final List<Problem> warnings;

    public Reporter() {
        this.errors = new LinkedList<>();
        this.warnings = new LinkedList<>();
    }

    /**
     * reports an error.
     *
     * @param position position
     * @param message  message
     * @return problem
     */
    public Problem error(final Position position,
                         final String message) {
        final Problem problem = new Problem(position, message);
        errors.add(problem);
        return problem;
    }

    /**
     * reports a warning.
     *
     * @param position position
     * @param message  message
     * @return problem
     */
    public Problem warn(final Position position,
                        final String message) {
        final Problem problem = new Problem(position, message);
        warnings.add(problem);
        return problem;
    }
}
